<template>
  <view v-if="open" style="padding-bottom: 100rpx">
    <u-navbar
      :placeholder="true"
      :titleStyle="{ color: '#ffffff' }"
      leftIconColor="#ffffff"
      bgColor="#3775cb"
      :autoBack="true"
      title="新增客户"
    >
    </u-navbar>
    <uni-card>
      <u--form labelPosition="left" :model="formData" :rules="rules" ref="form" labelWidth="68">
        <u-form-item label="客户名称" prop="name" ref="item1">
          <u--input v-model="formData.name" border="bottom"></u--input>
        </u-form-item>
        <u-form-item label="企业简称" prop="corpFullName" ref="item1">
          <u--input v-model="formData.corpFullName" border="bottom"></u--input>
        </u-form-item>
        <u-form-item label="企业全称" prop="corpName" ref="item1">
          <u--input v-model="formData.corpName" border="bottom"></u--input>
        </u-form-item>
        <u-form-item label="企业职位" prop="positionName" ref="item1">
          <u--input v-model="formData.positionName" border="bottom"></u--input>
        </u-form-item>
        <u-form-item label="身份证号" prop="idCard" ref="item1">
          <u--input v-model="formData.idCard" border="bottom"></u--input>
        </u-form-item>
      </u--form>
      <u-button type="primary" text="提 交" @click="submitForm"></u-button>
    </uni-card>
  </view>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { getCustomerAPI, postCustomerAPI } from '@/services/customer'
import FollowRecord from '@/pagesCustomer/customer/journey/followRecord.vue'
import Send from '@/pagesCustomer/customer/send.vue'
import Contact from '@/pagesCustomer/customer/journey/contact.vue'
import CustomerLog from '@/pagesCustomer/customer/journey/customerLog.vue'
import Opportunity from '@/pagesCustomer/customer/journey/opportunity.vue'
import { postFollowRecordAPI, putFollowRecordAPI } from '@/services/followRecord'
// 接收页面参数
const query = defineProps<{
  customerId: string
}>()
const open = ref(false)

const formData = ref<any>({
  dynamicTags: [],
  customerId: undefined,
  name: undefined,
  avatar: undefined,
  corpName: undefined,
  corpFullName: undefined,
  positionName: undefined,
  type: undefined,
  gender: undefined,
  laterFollowTime: undefined,
  entryType: undefined,
  cusTypeId: undefined,
  followStageId: undefined,
  idCard: undefined,
  birthday: undefined,
  nationality: undefined,
  marriage: undefined,
  education: undefined,
  tagIds: undefined,
})
const rules = ref<any>({
  name: {
    type: 'string',
    required: true,
    message: '请填写客户名称',
    trigger: ['blur', 'change'],
  },
})

const submitForm = async (e) => {
  const res = await postCustomerAPI(formData.value)
  uni.navigateBack({
    delta: 1,
  })
}

// 组件挂载完毕
onMounted(() => {
  open.value = true
})
</script>

<style lang="scss">
page {
  background-color: #f7f7f7;
  height: 100%;
}
</style>
